<html>
<head>
<!--
<script src="http://maps.google.cn/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"></script>
<script src="http://maps.google.cn/maps/api/js?sensor=false"></script>
-->
<script src="http://maps.google.cn/maps/api/js?sensor=false"></script>

<script>
var map;
var myCenter=new google.maps.LatLng(51.508742,-0.120850);
var x=new google.maps.LatLng(52.395715,4.888916);
var stavanger=new google.maps.LatLng(58.983991,5.734863);
var amsterdam=new google.maps.LatLng(52.395715,4.888916);
var london=new google.maps.LatLng(51.508742,-0.120850);

function initialize()
{
var bounds = new google.maps.LatLngBounds();
bounds.extend(stavanger);
bounds.extend(amsterdam);
bounds.extend(x);

var geocoder = new google.maps.Geocoder();  
    geocoder.geocode( {  
        'address' : "北京市,东城区,东直门"  
    }, function(results, status) {  
        if (status == google.maps.GeocoderStatus.OK) {  
            myLatLng = results[0].geometry.location;  
            //results数组里有很多有用的信息，包括坐标和返回的标准位置信息  
        } else {  
            alert(interGeoAnalysisFailed);  
        }  
    });  

var mapProp = {
  center:myCenter,
  zoom:4,
  disableDefaultUI:false,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };

    map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
    map.fitBounds(bounds);

    // 地图坐标锚点
    var marker=new google.maps.Marker({
        position:myCenter,
        // animation:google.maps.Animation.BOUNCE
    });

    marker.setMap(map);

    // 信息提示窗口
    var infowindow = new google.maps.InfoWindow({
        content:"测试信息"
    });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);
    });

    google.maps.event.addListener(map, 'click', function(event) {
        placeMarker(event.latLng);
    });



    // 折线
    var myTrip=[stavanger,amsterdam,london];
    var flightPath=new google.maps.Polyline({
        path:myTrip,
        strokeColor:"#8800FF",
        strokeOpacity:0.5,
        strokeWeight:3
    });

    flightPath.setMap(map);



}

function placeMarker(location) {
  var marker = new google.maps.Marker({
    position: location,
    map: map,
  });
  var infowindow = new google.maps.InfoWindow({
    content: 'Latitude: ' + location.lat() +
    '<br>Longitude: ' + location.lng()
  });
  infowindow.open(map,marker);
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
